package soundwave.com.demo.list;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;

import soundwave.com.demo.R;
import soundwave.com.demo.adpater.ViewpagerList_adapert;
import soundwave.com.demo.test.ViewpagerList_item_test;
import soundwave.com.demo.test.Viewpager_test;

/**
 * Created by xu on 2017/4/16.
 */

public class ViewpagerList extends Activity {
    private TextView back;
    private TextView title;
    private TextView search;
    private ListView tellphone_list;
    private ArrayList<Viewpager_test>conntent;
    private Context context=this;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.viewpager_list);
        initView();
        onclik();
        Viewpager_test common_tellphoneTest=getIntent().getParcelableExtra("viewpager_test");
        title.setText(common_tellphoneTest.getTitle());

        conntent=new ArrayList<>();
        Viewpager_test common_tellphoneTest1=new Viewpager_test();
        common_tellphoneTest1.setConntent("广东省深圳市龙华区");
        conntent.add(common_tellphoneTest1);
        Viewpager_test common_tellphoneTest2=new Viewpager_test();
         common_tellphoneTest2.setConntent("龙华区白石龙老村");
        conntent.add(common_tellphoneTest2);

        ViewpagerList_adapert common_tellphoneAdapert=new ViewpagerList_adapert(context,R.layout.viewpagerlist_conntent,conntent);
        tellphone_list.setAdapter(common_tellphoneAdapert);
        common_tellphoneAdapert.notifyDataSetChanged();



    }

    private void initView() {
        back = (TextView) findViewById(R.id.back);
        title = (TextView) findViewById(R.id.title);
        search = (TextView) findViewById(R.id.search);
        tellphone_list = (ListView) findViewById(R.id.tellphone_list);
    }
    private void onclik(){
        tellphone_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Viewpager_test viewpager_test= (Viewpager_test) adapterView.getItemAtPosition(i);

                ViewpagerList_item_test viewpagerList_item_test=new ViewpagerList_item_test();
                viewpagerList_item_test.setTitle(viewpager_test.getConntent());
                Intent intent=new Intent(context,ViewpagerList_item.class);
                intent.putExtra("viewpagerList_item_test",viewpagerList_item_test);
                startActivity(intent);
            }
        });
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }
}
